--赤中红鞘
local race_chiqiaohongzhon = fk.CreateSkill {
    name = "mcdh_race_chiqiaohongzhon"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

race_chiqiaohongzhon:addEffect('viewas',{
    pattern = "slash",
    card_filter = function(self, player,to_select, selected)
        return #selected < player.hp
    end,
    view_as = function(self,player, cards)
        if #cards ~= player.hp then
            return nil
        end
        local Card = Fk:cloneCard("slash")
        Card:addSubcards(cards)
        Card.skillName = self.name
        return Card
    end,
    before_use = function(self, player, use)
        use.extraUse = true
    end,
    enabled_at_play = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
    end,
    enabled_at_response = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
    end,
})

race_chiqiaohongzhon:addEffect('targetmod',{
    bypass_times = function(self, player, skill, scope, card)
        return card and scope == Player.HistoryPhase and table.contains(card.skillNames, "mcdh_race_chiqiaohongzhon")
    end,
})

race_chiqiaohongzhon:addEffect(fk.TargetSpecified,{
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        return data:isOnlyTarget(data.to) and table.contains(data.card.skillNames, "mcdh_race_chiqiaohongzhon") and target == player and to.hp > player:getHandcardNum()
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = data.to
        local n = math.abs(to.hp - player:getHandcardNum())
        local choices ={"#mcdh_race_chiqiaohongzhon1:::"..n,"#mcdh_race_chiqiaohongzhon2"}
        local  choice = room:askForChoice(player, choices, self.name,"#mcdh_race_chiqiaohongzhon-choose", nil)
        if choice == "#mcdh_race_chiqiaohongzhon1:::"..n then
            player:drawCards(n,self.name)
        else
            data.additionalDamage = (data.additionalDamage or 0) + 1
        end
    end,
})

Fk:loadTranslationTable {
    ["mcdh_race_chiqiaohongzhon"] = "赤中红鞘",
    ["#mcdh_race_chiqiaohongzhon_trigger"] = "赤中红鞘",
    [":mcdh_race_chiqiaohongzhon"] = "每回合限一次，你可以将体力值张牌当无次数限制的【杀】使用。此【杀】指定唯一目标后，若目标角色体力值大于你的手牌数，则你摸差值张牌或令此牌伤害+1。",
    ["#mcdh_race_chiqiaohongzhon-choose"] = "赤中红鞘: 选择一项",
    ["#mcdh_race_chiqiaohongzhon1"] = "1. 摸%arg张牌",
    ["#mcdh_race_chiqiaohongzhon2"] = "2. 令此牌伤害+1"
}

return race_chiqiaohongzhon